import datetime
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

#1、打开浏览器---驱动管理
ChromeIns = ChromeDriverManager().install()
#创建谷歌浏览器读取对象
driver = webdriver.Chrome(service=Service(ChromeIns))
driver.get("https://www.baidu.com")

#添加屏幕截图
#filename = "./test.png"
#filename = "./images/test.png"
#driver.save_screenshot(filename)

#进阶版本: 每次生成的图片文件都不一样
#百度首页
print(datetime.datetime.now())
filename = "autotest-" + datetime.datetime.now().strftime("%Y-%m-%d-%H%M%S")+".png"
driver.save_screenshot("./images/"+filename)



driver.quit()